package com.bizihang.validate.code.core.support;

import com.bizihang.validate.code.core.ValidateCode;
import com.bizihang.validate.code.core.ValidateCodeSender;
import com.bizihang.validate.code.core.support.sender.IOSender;

public class CodeSenderStrategy {
    private ValidateCodeSender sender;

    public CodeSenderStrategy(ValidateCode.TYPE codeType) {
        /**
         * 根据客户端的条件生成generator
         */
        switch (codeType) {
            case IMAGE:
                sender = new IOSender();
                break;
            case SMS:
            case EMAIL:
                sender = new IOSender();
                break;
            default:
                throw new RuntimeException("无法找到正确的验证码生成器");
        }
    }

    public void send(ValidateCode validateCode) {
        sender.send(validateCode);
    }
}
